package com.jlkf.controller;

import com.jlkf.pojo.ConfigManager;
import com.jlkf.pojo.User;
import com.jlkf.service.UserService;
import com.jlkf.temp.Page;
import com.platform.server.response.response.pojo.ReturnData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("user")
public class UserController {

	@Autowired
	private UserService userService;
	
	
	@RequestMapping("sendSMS")
	private Object sendSMS(@RequestBody String  json){
		return userService.sendSMS(json);
	}
	 //乘客列表赠送给用户优惠劵
	 @RequestMapping("sendACoupon")
	 @ResponseBody
	 public Object sendACoupon(@RequestBody String json){
			return userService.sendACoupon(json);
		}
	@RequestMapping("getList")
	public Object getUserList(String startTime,String endTime,String telephone,Integer sex,Integer isOnline,Integer pageNo,Integer pageSize,Integer isDeleted
			,String order,String sortname){
		return userService.getUserList(startTime, endTime, telephone, sex, isOnline, pageNo, pageSize,isDeleted,order,sortname);
	}
	//删除乘客
	@RequestMapping("deleteUser")
	public Object deleteUser(Long id){
		return userService.deleteUser(id);
	}
	//添加用户
	@RequestMapping("addUser")
	public Object addUser(@RequestBody String json,HttpServletRequest request){
		return userService.addUser(json,request);
	}
	
	//在线人数
	@RequestMapping("getOnLineNum")
	public Object getOnLineNum(){
		return userService.getOnLineNum();
	}
	//导出乘客列表
	@RequestMapping("exportUserList")
	public void exportUserList(String startTime,String endTime,String telephone,Integer sex,Integer isOnline,Integer pageNo,Integer pageSize,Integer isDeleted
			,String order,String sortname,HttpServletResponse response){
		userService.exportUserList(startTime, endTime, telephone, sex, isOnline, pageNo, pageSize,isDeleted,order,sortname,response);
	}
	
	//导出司机列表
	@RequestMapping("exportDriverList")
	@ResponseBody
	public void exportDriverList(String telephone,String createTime,String loginTime, Page page,HttpServletResponse response){
		userService.exportDriverList( telephone, createTime, loginTime,page,response);
	}
	
	@RequestMapping("getCity")
	public Object getCityList(Integer pageNo,Integer pageSize){
		return userService.getCityList(pageNo, pageSize);
	}

	
	//用户详情
	/*@GetMapping("/info")*/
	@RequestMapping(value="/info",method=RequestMethod.GET)
	public String getUserInfo(User user,Map<String,Object> map){
		if(user != null && user.getId()!= null){
			userService.getUserInfo(user,map);
		}
		return "appUser/info";
	}

	//禁用，启用
	/*@PostMapping("/update")*/
	@RequestMapping(value="/update",method=RequestMethod.POST)
	@ResponseBody
	public ReturnData updateUser(User user){
		if(user != null && user.getId() != null && user.getIsDeleted()!=null){
			return new ReturnData(userService.updateUser(user));
		}
		return new ReturnData(1,"参数错误");
	}
	
	//司机列表
	/*@GetMapping("/drivers")*/
	@RequestMapping(value="/drivers",method=RequestMethod.GET)
    @ResponseBody
	public ReturnData getDrivers(String createTimes,String loginTimes,User user, Page page){
	    return userService.getDrivers(createTimes,loginTimes,user,page);
    }

	//添加司机
	@RequestMapping("addDrivers")
	public ReturnData addDrivers(@RequestBody String json,HttpServletRequest request){
	    return userService.addDrivers(json,request);
    }
	
	
	
    //司机详情
   /* @GetMapping("/driver/info")*/
    @RequestMapping(value="/driver/info",method=RequestMethod.GET)
    public String getDriverInfo(User user,Map<String,Object> map) {
        if (user != null && user.getId() != null) {
            userService.getDriverInfo(user, map);
        }
        return "driver/info";
    }
    //取消订单设置
   /* @GetMapping("/driver/order/cancel/conf")*/
    @RequestMapping(value="/driver/order/cancel/conf",method=RequestMethod.GET)
	@ResponseBody
	public ReturnData cancelOrderConf(){
		return new ReturnData(userService.cancelOrderConf());
	}
	/*@PostMapping("/driver/order/cancel/conf")*/
	 @RequestMapping(value="/driver/order/cancel/conf",method=RequestMethod.POST)
	@ResponseBody
	public ReturnData orderConf(ConfigManager conf){
		return new ReturnData(userService.orderConf(conf));
	}
	 
	 //企业机构信息列表
	 @RequestMapping("getEnterpriseList")
	public Object getEnterpriseList(String company,String userAccount,Integer pageNo,Integer pageSize){
			return userService.getEnterpriseList( company, pageNo, pageSize,userAccount);
		}
	 //添加企业账号
	 @RequestMapping("addEnterprise")
	 @ResponseBody
	 public Object addEnterprise(@RequestBody String json){
			return userService.addEnterprise(json);
		}
	
	 
	 
	 //删除企业
	 @RequestMapping("deleteEnterprise")
	 public Object deleteEnterprise( String ids){
			return userService.deleteEnterprise(ids);
		}
	 //企业赠送优惠劵
	 @RequestMapping("userEnterpriseCoupon")
	 public Object userEnterpriseCoupon( Long qyId,Integer pageNo,Integer pageSize,String startTime,String endTime,String couponName,String couponNo,String couponCode,String giftedPeopleName){
			return userService.userEnterpriseCoupon(qyId,pageNo,pageSize,startTime,endTime,couponName,couponNo,couponCode,giftedPeopleName);
		} 
	 //导出企业用户
	 @RequestMapping("exportEnterprise")
	 public void exportEnterprise(String company,String userAccount,HttpServletResponse response,HttpServletRequest request){
		  userService.exportEnterprise(company,userAccount,response,request);
		}
	 
	 @RequestMapping("getQueryList")
		public Object getQueryList(String telephone,Integer pageNo,Integer pageSize,Integer identity){
			return userService.getList( telephone, pageNo, pageSize,identity);
		}
	 
	 //OA优惠劵发放列表  
	 @RequestMapping("getUserCouponList")
		public Object getUserCouponList(String couponNo,Integer pageNo,Integer pageSize,String couponCode,String couponName,String userName,String startTime,String endTime,String giftedPeopleName){
			return userService.getUserCouponList( couponNo, pageNo, pageSize,couponCode,couponName,userName,startTime,endTime,giftedPeopleName);
		} 
	 
	 //司机接单
	 @RequestMapping("getReceiveMileage")
		public Object getReceiveMileage(String startTime,String endTime,String licensePlate,String telephone,Integer carType,Integer pageNo,Integer pageSize){
			return userService.getReceiveMileage(startTime, endTime, licensePlate, carType,telephone,  pageNo, pageSize);
		}
	 //送礼记录
	 @RequestMapping("giftGivingRecords")
	 public Object giftGivingRecords(@RequestBody String json){
			return userService.giftGivingRecords(json);
		}
}
